package com.tangfuzhong.test;

import com.tangfuzhong.bean.Fish;
import com.tangfuzhong.ext.LogEvent;
import org.junit.Test;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.tangfuzhong.config.Config10_Ext_listen_event_registry_BeanFactoryPostProcessor;

public class IOCTest_10_Ext_listen_event_registry_BeanFactoryPostProcessor {
	
	@Test
	public void test01(){
		AnnotationConfigApplicationContext applicationContext  = new AnnotationConfigApplicationContext(Config10_Ext_listen_event_registry_BeanFactoryPostProcessor.class);
		
		
		//发布事件:ApplicationEvent
		applicationContext.publishEvent(new ApplicationEvent(new String("tang发布的事件")) {
		});
		//发布事件:LogEvent
		applicationContext.publishEvent(new LogEvent() {
		});

		//发现fish的值已经被MyBeanFactoryPostProcessor更改
		Fish fish = applicationContext.getBean(Fish.class);
		System.out.println(fish);

		applicationContext.close();
	}

}
